
import java.io.*;
import java.net.*;
public class GetURL{
	
	public static void main (String args[]) throws Exception{
		
		//String string = URLEncoder.encode("porn", "UTF-8");
		
		
		URL url= new URL("http://gainesville.craigslist.org/search/sss?query=monitor&hasPic=1");
		URLConnection connection = url.openConnection();
		connection.setDoOutput(true);
		OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream());
		out.close();
		
		BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
	   
		String inputline;
		
		BufferedWriter fileWriter = new BufferedWriter(new FileWriter("/home/kes/Desktop/page"));
		while((inputline=in.readLine())!=null){
		   fileWriter.write(inputline);
		   fileWriter.newLine();
		}
		fileWriter.close();
		in.close();
	   
	   BufferedReader fileReader = new BufferedReader(new FileReader("/home/kes/Desktop/page"));
	   String fileLine;
	   while((fileLine=fileReader.readLine())!=null){
		   
	   }
	  }
	}
